package cn.cloud.jianghai.jianghaicommon.entity;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Jiang.h
 * created 2022/5/21 16:34
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R<T> {

    private String code;

    private String msg;

    private T data;

    private Boolean status;

    public R(T object) {
        this.data = object;
    }

    public static <T> R<T> success(Object object) {
        return success("200", "请求成功", object);
    }

    public static R success(String code, String msg, Object object) {
        return new R(code, msg, object, Boolean.TRUE);
    }


    public static R fail(String msg) {
        return fail("500", msg);
    }

    public static R fail(String code, String msg) {
        return new R(code, msg, null, Boolean.FALSE);
    }
}
